package com.lxf.cloudproduct.bean;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author 罗兴发
 * @data 2025/5/9 10:47
 * @description：商品实体类
 */
@Data
@Accessors(chain = false)  //链式结构
@NoArgsConstructor   //无参构造函数
@Document(indexName = "es") //创建的es库名称
public class ProductBean implements Serializable {
    private static final long serialVersionUID = 1L;//控制序列化版本兼容
    @Id
    @ExcelProperty(value = "商品编码",index = 0)
    @Field(type = FieldType.Keyword)
    private String goodCode;//商品编码

    @ExcelProperty(value = "商品名称",index = 1)
    @Field(type = FieldType.Text)
    private String goodName;//商品名称

    @ExcelProperty(value = "商品库存",index = 2)
    @Field(type = FieldType.Integer)
    private Integer goodCount;//商品库存

    @ExcelProperty(value = "商品单价",index = 3)
    @Field(type = FieldType.Double)
    private BigDecimal goodPrice;//商品单价

    @ExcelIgnore
    @Field(type = FieldType.Integer)
    private Integer isUp;//是否上架：0否 1是

    @ExcelIgnore
    @Field(type = FieldType.Integer)
    private Integer likeNum;//点赞量

    @ExcelIgnore
    @Field(type = FieldType.Integer)
    private Integer isLike;//是否点赞

    @ExcelIgnore
    @Field(type = FieldType.Integer)
    private Integer collectNum;//收藏量

    @ExcelIgnore
    @Field(type = FieldType.Integer)
    private Integer isCollect;//是否收藏

    @ExcelIgnore
    @Field(type = FieldType.Integer)
    private Integer relayNum;//转发量

    @ExcelIgnore
    @Field(type = FieldType.Integer)
    private Integer userId;//用户ID

    @ExcelIgnore
    @Field(type = FieldType.Integer)
    private Integer objType;//类型编码

    @Field(type = FieldType.Nested)
    List<ProductImgBean> imgList;

    @ExcelIgnore
    @Field(type = FieldType.Date, format = DateFormat.basic_date_time)
    private String addTime;//添加时间
}
